<template>
  <div class="login-container">
    <div class="login-box">
      <img src="/images/logo.png" alt="logo" class="logo">
      <h2>家校沟通管理系统</h2>
      <form @submit.prevent="handleLogin">
        <input type="text" v-model="username" placeholder="用户名" required>
        <input type="password" v-model="password" placeholder="密码" required>
        <select v-model="role" required>
          <option value="">选择角色</option>
          <option value="parent">家长（H5）</option>
          <option value="counselor">辅导员（PC）</option>
          <option value="admin">系统管理员（PC）</option>
        </select>
        <div class="remember-me" style="text-align: left; margin: 10px 0;">
          <input type="checkbox" id="remember" v-model="remember">
          <label for="remember">记住密码</label>
        </div>
        <button type="submit">登录</button>
      </form>
      <div class="login-footer">
        <a href="#" @click.prevent="forgotPassword">忘记密码？</a>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Login',
  data() {
    return {
      username: '',
      password: '',
      role: '',
      remember: false
    }
  },
  methods: {
    handleLogin() {
      if (!this.role) {
        alert('请选择角色！');
        return;
      }
      if (this.role === 'parent') {
        this.$router.push('/parent');
      } else if (this.role === 'counselor') {
        this.$router.push('/counselor');
      } else if (this.role === 'admin') {
        this.$router.push('/admin');
      }
    },
    forgotPassword() {
      alert('忘记密码功能正在开发中...');
    }
  }
}
</script>

<style scoped>
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-box {
  background: white;
  padding: 40px;
  border-radius: 10px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
  animation: fadeIn 0.5s ease-in-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}
.logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  display: block;
}
h2 {
  text-align: center;
  color: #333;
  margin-bottom: 30px;
  font-size: 24px;
}
form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
input, select {
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 16px;
  transition: border-color 0.3s;
}
input:focus, select:focus {
  outline: none;
  border-color: #667eea;
}
button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 12px;
  border: none;
  border-radius: 5px;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s;
}
button:hover {
  transform: translateY(-2px);
}
.login-footer {
  margin-top: 20px;
  font-size: 14px;
  color: #666;
  text-align: center;
}
.login-footer a {
  color: #007bff;
  text-decoration: none;
}
.login-footer a:hover {
  text-decoration: underline;
}
</style> 